Function.prototype.myBind = function (context, ...args) {
    // 把方法取出来
    const fn = this
    args = args || []
    return function newFn(...newFnArgs) {
        // 1. 作为构造函数
        if(this instanceof newFn) {
            return new fn(...args,...newFnArgs)
        } 
        // 2. 普通函数直接调用
        return fn.apply(context,[...args,...newFnArgs])
    }
};
let obj = {
    age:18,
    getAge: function(name,job){
        this.name = name;
        this.job = job
        console.log(name +'现在'+ this.age+'岁,'+'工作是'+job);
    }
}
this.age = 20
let _fn = obj.getAge
// 作为构造函数时
let newObj =  _fn.myBind(obj)
let o = new newObj('小红','小明')
console.log(o);

// 作为函数调用时
_fn.myBind(obj)('小红','小明')
